package com.yuexi.web;

import com.yuexi.domain.payment.alipay.AliPayDomain;
import com.yuexi.domain.payment.alipay.bo.AliPayBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jie
 * @date 2023/4/10 -12:00
 */
@Api(tags = "支付宝支付")
@RequestMapping("alipay")
@RestController
public class AliPayController {

    @Autowired
    private AliPayDomain domain;

    @ApiOperation("支付")
    @PostMapping("pay")
    public Object micropay(AliPayBO bo) throws Exception {
        bo.setOutTradeNo(String.valueOf(System.currentTimeMillis()));
        bo.setSubject("123");
        return domain.pay(bo);
    }

    @ApiOperation("查询")
    @PostMapping("query")
    public Object query(String outTradeNo) throws Exception {
        return domain.query(outTradeNo);
    }

    @ApiOperation("退款")
    @PostMapping("refund")
    public Object refund(String outTradeNo, String refundAmount) throws Exception {
        return domain.refund(outTradeNo, refundAmount);
    }
}
